#include <cstdio>
#include "vl_thread_pool.h"

using namespace VL;

int main(int argc, const char ** argv) {
	VLThreadPool pool(5, 5, 5);
	pool.initThreadPool();
	for(int i = 0 ; i < 1 ; i ++) {
		auto futurePtr = VLFuture::newFuture<int, int>();
		futurePtr->as<int, int>()->then([](const std::shared_ptr<int>& dataPtr) {
			printf("future result: %d\n", *dataPtr);
		})->error([](const std::shared_ptr<int>& errorPtr) {
			printf("future error: %d\n", *errorPtr);
		})->complete([]() {
			printf("completed\n");
		});

		pool.exec([futurePtr] {
			futurePtr->as<int, int>()->setData(1);
		});
		
		printf("future result: %d\n", *(futurePtr->as<int, int>()->getDataOrThrow()));
	}

	pool.waitForAllTaskDone();
	return 0;
}
